﻿using System;
using System.Diagnostics.Contracts;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.OfficeArt
{
    internal class OfficeArtBlipPNG : OfficeArtStandardBlip
    {
        private PngFormat _nativeFormat;

        public OfficeArtBlipPNG(byte[] data): base (data)
        {
            this.NativeFormat = PngFormat.One;
        }

        public OfficeArtBlipPNG()
        {
        }

        public override RecType RecordType
        {
            get { return RecType.OfficeArtBlipPNG; }
        }


        protected override string Extension
        {
            get { return "png"; }
        }

        protected override ushort Format
        {
            get { return (ushort) NativeFormat;   }
            set { NativeFormat = (PngFormat) value; }
        }

        protected PngFormat NativeFormat
        {
            get {
                Contract.Ensures(Enum.IsDefined(typeof(PngFormat), Contract.Result<PngFormat>()));

                return _nativeFormat;
            }
            set {
                Contract.Requires(Enum.IsDefined(typeof (PngFormat), value));
                _nativeFormat = value;
            }
        }

        protected override UidCount HasTwoIds()
        {
            switch (NativeFormat)
            {
                case PngFormat.One:
                    return UidCount.One;
                case PngFormat.Two:
                    return UidCount.Two;
                default:
                    throw new NotSupportedException();
            }
        }


        internal override MSOBLIPTYPE Type
        {
            get { return MSOBLIPTYPE.msoblipPNG; }
        }
        internal enum PngFormat : ushort
        {
            One = 0x6E0,
            Two = 0x6E1,
        }
    }

}